﻿using JZ.JiangSu.Model.Entity;
using System.Collections;
using System.Collections.Generic;

namespace JZ.JiangSu.IRepository
{
    public interface IUserRepository : IBaseRepository<User>
    {
        /// <summary>
        /// 根据登录名获取用户信息
        /// </summary>
        /// <param name="loginName"></param>
        /// <returns></returns>
        IList<User> GetUserByPhone(string loginName);
        /// <summary>
        /// 根据ip和时间获取用户
        /// </summary>
        /// <param name="ip"></param>
        /// <returns></returns>
        int GetUserByIPinHoursCount(string ip);
        /// <summary>
        /// 修改密码(已知旧密码)
        /// </summary>
        /// <param name="id"></param>
        /// <param name="newPwd">加密后的新密码</param>
        /// <returns></returns>
        int ChangePwd(int id, string newPwd);



        /// <summary>
        /// 获取帐号下子帐号的个数。
        /// 即MasterId=父帐号Id
        /// </summary>
        /// <param name="masterId">user表的MasterId字段值</param>
        /// <returns>以这个Id为MasterId的帐号的数量：int</returns>
        int GetUserChildCount(int masterId);



        /// <summary> 获取指定企业账号的所有有效子账号的个数--不排除子账号可能是个人用户的可能性 </summary>
        /// <param name="userId">企业账号Id</param>
        /// <param name="isExcludeSelf">是否排除企业账号本身(True->排除,False->不排除)</param>
        /// <param name="subAccountType">子账号类型(True->公司,False->个人,null->则默认两者皆可)</param>
        /// <returns></returns>
        int GetUserSubAccountCount(int userId, bool isExcludeSelf, bool? subAccountType);
        /// <summary> 分页获取指定企业账号的所有有效子账号的信息集合--不排除子账号可能是个人用户的可能性</summary>
        /// <param name="start">分页开始位置</param>
        /// <param name="pageSize">每页显示的条数</param>
        /// <param name="userId">企业账号Id</param>
        /// <param name="isExcludeSelf">是否排除企业账号本身(True->排除,False->不排除)</param>
        /// <param name="subAccountType">子账号类型(True->公司,False->个人,null->则默认两者皆可)</param>
        /// <returns></returns>
        List<User> GetUserInfoByMasterId(int start, int pageSize, int userId, bool isExcludeSelf, bool? subAccountType);
        /// <summary> 分页获取指定企业账号的所有有效子账号的信息集合--不排除子账号可能是个人用户的可能性</summary>
        /// <param name="start">分页开始位置</param>
        /// <param name="pageSize">每页显示的条数</param>
        /// <param name="userId">企业账号Id</param>
        /// <param name="isExcludeSelf">是否排除企业账号本身(True->排除,False->不排除)</param>
        /// <param name="subAccountType">子账号类型(True->公司,False->个人,null->则默认两者皆可)</param>
        /// <returns></returns>
        List<User> GetUserInfoByMasterIdWithInfo(int start, int pageSize, int userId, bool isExcludeSelf, bool? subAccountType);

        /// <summary>
        /// 获取指定企业账号的所有有效子账号的信息集合 搜索相关信息使用此方法
        /// </summary>
        /// <param name="userId">企业账号Id</param>
        /// <param name="isExcludeSelf">是否排除企业账号本身(True->排除,False->不排除)</param>
        /// <param name="subAccountType">子账号类型(True->公司,False->个人,null->则默认两者皆可)</param>
        /// <param name="sechPhone"></param>
        List<User> GetUserInfoByMasterIdSech(int userId, bool isExcludeSelf, bool? subAccountType, string sechPhone);
        /// <summary> 根据公司名称查询当前公司是否存在 </summary>
        /// <param name="companyName">公司名称</param>
        /// <returns></returns>
        User GetCompanyInfoByName(string companyName);

        List<User> GetUserListByMasterId(int userId);
        /// <summary>
        /// 分配简历列表搜索，以手机号进行搜索
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="phonenum"></param>
        /// <returns></returns>
        List<User> GetUserListByPhoneSearchPayCoupon(int userId, string phonenum);

        /// <summary> 根据航母号ID查询飞机号集合 置顶券 </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        List<User> GetUserListByMasterIdOnTopCoupon(int userId);


        int UpdateUserPhoneById(int userId, string phone);

        /// <summary> 企业账号关联或取消关联子账号/更改用户账号的级别，升级或取消成企业账号(同时绑定或还原企业账号Id) 
        /// </summary>
        /// <param name="userIds">用户Id</param>
        /// <param name="isMaster">True--升级/False--取消</param>
        /// <param name="masterId">企业账号Id</param>
        /// <returns></returns>
        int UpdateUserIsMasterById(int[] userIds, bool isMaster, int masterId);

        /// <summary> 企业主账号关联子账号时，子账号资料要与主账号同步 
        /// </summary>
        /// /// <param name="masterId">当前企业主账号ID</param>
        /// <returns></returns>
        int UpdateChildInfoByMasterId(int masterId);

        /// <summary></summary>
        /// <param name="list"></param>
        /// <returns></returns>
        int UpdateTopCoupon(List<KeyValuePair<int, int>> list);


        int UpdateUserEntity(User user);

        int AutoUpdateEntity(Hashtable ht);

        User GetUserByResumeId(int resumeId);
        /// <summary> 给指定用户分配指定的权限 </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="power">权限</param>
        /// <returns></returns>
        int UpdateUserPermissionByUserId(int userId, int power);
    }
}
